package com.popcorn.notice.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.popcorn.action.Action;
import com.popcorn.action.ActionForward;
import com.popcorn.notice.dao.NoticeDAO;

public class NoticePCheckAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		NoticeDAO noticeDao = new NoticeDAO();
		ActionForward forward = new ActionForward();
		boolean result = false;

		HttpSession session = request.getSession();
		String select = request.getParameter("select");
		String idx = request.getParameter("idx");
		
		result = noticeDao.sessionCheck((String)session.getAttribute("login"),(String)request.getParameter("PASSWORD"), idx);  // 닉네임세션 불러옴
		
		if(result){
			System.out.println("확인 성공");
			forward.setRedirect(true);
	   		forward.setPath("NoticeP_OK.jsp?select="+select+"&idx="+idx); 
	   		return forward;
		}
		else{
			System.out.println("확인 실패");
			forward.setRedirect(true);
   			forward.setPath("NoticeP_Error.jsp?select="+select+"&idx="+idx); 
   			return forward;
		}
	}
}